In the event of technical difficulties with Szkopuł, please contact us via email at [email protected].
If you would like to talk about tasks, solutions or technical problems, please visit our Discord servers. They are moderated by the community, but members of the support team are also active there.
Psst... Ruszyły zawody olimpiady informatycznej dla uczniów szkół podstawowych i średnich. Zadania na tych konkursach są bardzo podobne do zadań, które rozwiązujesz, tutaj, na Szkopule. Zobacz więcej:
- dla uczniów szkół podstawowych: oij.edu.pl/start/
- dla uczniów szkół średnich: oi.edu.pl/l/jak_zaczac/
Elections are coming and the mayor of Bytetown decided to organize
an athletic competition to increase his odds.
Unfortunately there is no athletic stadium in Bytetown, so all parts of the
competition will have to be held in the streets.
The mayor decided to limit the competition only to running events and asked you for
help with planning the troutes.
There are street junctions and streets in Bytetown.
The streets can be used to travel between any pair of junctions.
Every route must start at a junction, lead along several streets
and finish at some other junction.
The mayor would like to organize as many events simultaneously as possible, so
the number of routes should be as large as possible.
Due to safety reasons no two routes may have a common junction or street.
Moreover not every junction can be used as a starting or ending point
of a race.
Input
The first line of the input contains a single integer
(): the number of junctions in Bytetown.
The junctions are numbered from to .
The following lines contain descriptions of the streets; each of them
consists of two integers and (, ), separated
by a single space: the numbers of junctions that are endpoints of the street.
The line number contains one integer (): the
number of junctions that can serve as a starting or ending point of a race.
The last line of the input contains distinct space-separated numbers:
the numbers of those junctions, each in the range .
Output
The first and only line of the output should contain one integer,
the maximal possible number of running events that can be held
in Bytetown simultaneously.